/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package datas;

import Beans.UserRole;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**

 @author jtanguay
 */
public interface UserRoleMapper {

  final String SELECT_Role_FOR_USER = "SELECT * FROM user_role WHERE idUser=#{idUser}";
  final String UPDATE_Role_FOR_USER = "UPDATE user_role SET idRole=#{idRole} WHERE idUser = #{idUser} And idRole=#{idRoleToUpgrade}";

  @Select(SELECT_Role_FOR_USER)
  List<UserRole> getAllRolesForUser(int userId);

  @Update(UPDATE_Role_FOR_USER)
  int upGradeAccount(@Param("idRole") int idRole, @Param("idUser") int idUser, @Param("idRoleToUpgrade") int idRoleToUpgrade);
}
